package cn.kai.basic.controller;

import cn.kai.basic.service.ILoginService;
import cn.kai.basic.util.AjaxResult;
import cn.kai.basic.vo.LoginAccountVo;
import cn.kai.basic.vo.WeChatVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private ILoginService loginService;

    @PostMapping("/account")
    public AjaxResult accountLogin(@RequestBody @Valid LoginAccountVo vo){
        Map<String, Object> map = loginService.accountLogin(vo);
        return AjaxResult.me().success(map);
    }

    @PostMapping("/wechat")
    public AjaxResult accountWechat(@RequestBody WeChatVo vo){
        return loginService.accountWechat(vo);
    }


    @PostMapping("/wechat/binder")
    public AjaxResult wechatBinder(@RequestBody WeChatVo vo){
        return loginService.wechatBinder(vo);
    }
}
